import NetEngine


server = NetEngine.NetEngineServer()


def server_notify(event, session_p):
    print("server_notify", event, session_p)


def data_notify(session_p, is_recv, data):
    print("data_notify", session_p, is_recv, data.hex())
    if is_recv:
        server.send(session_p, data)


server.register_data_notify(data_notify)
server.register_server_event_notify(server_notify)
server.start_listen(50200)
print('输入\'q\'停止监听，输入\'e\'开始监听，已开始监听')
while True:
    ch = input()
    if ch == 'q':
        server.stop_listen()
    elif ch == 'e':
        server.start_listen(50200)
